<template>
    <div class="app-container">
        <el-form label-width="80px">
            <el-form-item label="ID">
                <el-input v-model="group.id" disabled></el-input>
            </el-form-item>
            <el-form-item label="组名称">
                <el-input v-model="group.name"></el-input>
            </el-form-item>
            <el-form-item label="组备注">
                <el-input v-model="group.remark"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="edit()">编辑</el-button>
                <el-button @click="back()">返回</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import resourceGroupApi from '../../api/resourceGroup'
    import {Message, MessageBox} from 'element-ui'


    export default {
        name: "resource-group-manager-edit",
        props:['groupId'],
        data:function () {
            return {
                group:{
                    id:'',
                    name:'',
                    remark:''
                }
            }
        },
        mounted:function () {
            const _this = this;
            _this.group.id = _this.groupId;
            resourceGroupApi.findById(_this.group.id)
                .then(function (data) {
                    _this.group = data;
                })
        },
        methods:{
            edit:function () {
                console.log(this.groupId)
                const _this = this;
                resourceGroupApi.edit(_this.group)
                    .then(function (data) {
                        if (data.success){
                            Message.success('编辑成功')
                            return
                        }
                        Message.error('编辑失败')
                    }).catch(function () {
                        Message.error('编辑失败')
                    })
            },
            back:function () {
                this.$router.back(-1)
            }
        }


    }
</script>

<style scoped>

</style>
